package com.linkhub.oms.admin.modules.track.domain.request;

import com.alibaba.fastjson.annotation.JSONField;
import com.linkhub.oms.entity.innerproperties.TrackEventInfoEntity;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author Redball
 * @version 1.0.0
 * @Description TrackRequest
 * @createTime 2024/10/26 下午6:07
 */
@Data
@NoArgsConstructor
public class TrackRequest {

    @JSONField(name = "number")
    private String number;

    @JSONField(name = "carrier")
    private Integer carrier;

    @JSONField(name = "param")
    private String param;

    @JSONField(name = "tag")
    private String tag;

    @JSONField(name = "track_info")
    private TrackInfo trackInfo;

    @NoArgsConstructor
    @Data
    public static class TrackInfo {

        @JSONField(name = "shipping_info")
        private ShippingInfo shippingInfo;

        @JSONField(name = "latest_status")
        private TrackStatus latestStatus;

        @JSONField(name = "latest_event")
        private TrackEventInfoEntity latestEvent;

        @JSONField(name = "time_metrics")
        private TimeMetrics timeMetrics;

        @JSONField(name = "milestone")
        private List<Milestone> milestone;

        @JSONField(name = "misc_info")
        private MiscInfo miscInfo;

        @JSONField(name = "tracking")
        private Tracking tracking;
    }

    @NoArgsConstructor
    @Data
    public static class ShippingInfo {
        @JSONField(name = "shipper_address")
        private TrackEventInfoEntity.TrackAddress shipperAddress;
        @JSONField(name = "recipient_address")
        private TrackEventInfoEntity.TrackAddress recipientAddress;
    }

    @NoArgsConstructor
    @Data
    public static class TrackStatus {
        @JSONField(name = "status")
        private String status;
        @JSONField(name = "subStatus")
        private String sub_status;
        @JSONField(name = "sub_status_descr")
        private String subStatusDescr;
    }

    @NoArgsConstructor
    @Data
    public static class TimeMetrics {
        @JSONField(name = "days_after_order")
        private Integer daysAfterOrder;
        @JSONField(name = "days_of_transit")
        private Integer daysOfTransit;
        @JSONField(name = "days_of_transit_done")
        private Integer daysOfTransitDone;
        @JSONField(name = "days_after_last_update")
        private Integer daysAfterLastUpdate;
        @JSONField(name = "estimated_delivery_date")
        private EstimatedDeliveryDate estimatedDeliveryDate;
    }

    @NoArgsConstructor
    @Data
    public static class EstimatedDeliveryDate {
        @JSONField(name = "source")
        private String source;
        @JSONField(name = "from")
        private String from;
        @JSONField(name = "to")
        private String to;
    }

    @NoArgsConstructor
    @Data
    public static class Milestone {
        @JSONField(name = "key_stage")
        private String keyStage;
        @JSONField(name = "time_iso")
        private String timeIso;
        @JSONField(name = "time_utc")
        private String timeUtc;
    }

    @NoArgsConstructor
    @Data
    public static class MiscInfo {
        @JSONField(name = "risk_factor")
        private Integer riskFactor;
        @JSONField(name = "service_type")
        private String serviceType;
        @JSONField(name = "weight_raw")
        private String weightRaw;
        @JSONField(name = "weight_kg")
        private String weightKg;
        @JSONField(name = "pieces")
        private String pieces;
        @JSONField(name = "dimensions")
        private String dimensions;
        @JSONField(name = "customer_number")
        private String customerNumber;
        @JSONField(name = "reference_number")
        private String referenceNumber;
        @JSONField(name = "local_number")
        private String localNumber;
        @JSONField(name = "local_provider")
        private String localProvider;
        @JSONField(name = "local_key")
        private String localKey;
    }

    @NoArgsConstructor
    @Data
    public static class Tracking {
        @JSONField(name = "providers_hash")
        private String providersHash;
        @JSONField(name = "providers")
        private List<Provider> providers;
    }

    @NoArgsConstructor
    @Data
    public static class Provider {
        @JSONField(name = "provider")
        private String provider;
        @JSONField(name = "service_type")
        private String serviceType;
        @JSONField(name = "latest_sync_status")
        private String latestSyncStatus;
        @JSONField(name = "latest_sync_time")
        private String latestSyncTime;
        @JSONField(name = "events_hash")
        private String eventsHash;
        @JSONField(name = "events")
        private List<TrackEventInfoEntity> events;
    }

}
